﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using WebService.DataAccess;using WebService.BusinessEntities;

namespace WebService.DataAccess
{
    /// <summary>
    /// Construct a LoginAudit object from a datareader.
    /// </summary>
    internal class GET_LOGIN_AUDIT_PROCFactory : IDomainObjectFactory<LoginAudit>
    {
        public LoginAudit Construct(IDataReader reader)
        {
            LoginAudit loginAudit = new LoginAudit();

            int user_idIndex = reader.GetOrdinal("user_id");
            if (!reader.IsDBNull(user_idIndex))
            {
                loginAudit.user_id = reader.GetInt32(user_idIndex);

            }

            int logon_dateIndex = reader.GetOrdinal("logon_date");
            if (!reader.IsDBNull(logon_dateIndex))
            {
                loginAudit.logon_date = reader.GetDateTime(logon_dateIndex);

            }

            int logout_dateIndex = reader.GetOrdinal("logout_date");
            if (!reader.IsDBNull(logout_dateIndex))
            {
                if (!reader.IsDBNull(logout_dateIndex))
                {
                    loginAudit.logout_date = reader.GetDateTime(logout_dateIndex);
                }

            }

            int statusIndex = reader.GetOrdinal("status");
            if (!reader.IsDBNull(statusIndex))
            {
                loginAudit.status = reader.GetBoolean(statusIndex);

            }


            return loginAudit;
        }
    }
}

